package cn.farm.farm.Mapper.CommonMapper;

import cn.farm.farm.Entity.Common.Peststress;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface PestMapper {
    @Select("select diseaseID,chineseName,latinName,alias,pestImage from peststress where chineseName like CONCAT('%',#{name},'%')")
    @Results({
            @Result(column = "pestImage" , property = "pestimage",
                    many=@Many(select = "cn.farm.farm.Mapper.CommonMapper.MatchMapper.getimageID",fetchType= FetchType.EAGER))
    })
    List<Peststress> likeSelect(@Param(value = "name") String name);


    @Select("select count(*) from peststress where category in (select bioID from biologycategory where species = #{species}) ")
    Integer selectByCate(@Param(value = "species") String species);

    @Select("select diseaseID,chineseName,latinName,alias,pestImage from peststress where category in (select bioID from biologycategory where species = #{species} ) ")
    @Results({
            @Result(column = "pestImage" , property = "pestimage",
                    many=@Many(select = "cn.farm.farm.Mapper.CommonMapper.MatchMapper.getimageID",fetchType= FetchType.EAGER))
    })
    List<Peststress> selectByCategory(@Param(value = "species") String species);
}
